home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / language / embedded / m68k / fbug68k.arc / GETLINEP.ORT < prev    next >
Text File  |  1989-08-17  |  3KB  |  136 lines

  1. #include"userdef.h"
  2.  
  3. /*
  4. This routine inputs a string from the terminal, strips of leading
  5. blanks, allows for destructive backspacing while on the line, and returns 
  6. the number of arguments seperated by a space, along with the line.
  7. */
  8.  
  9. getline(buffer)
  10. char *buffer;    /* string to put the typed line into */
  11. {
  12. register char ch;    /* charachter inputed */
  13. register char *bufptr;    /* pointer to within gbuffer */
  14. register int length;    /* length of string inputed */
  15. register int intext;    /* flag for being between text delimiters or blanks */
  16. register int i;        /* loop counter */
  17.  
  18.     length = 0;
  19.     ch = ' ';
  20.     bufptr = buffer;
  21.     *bufptr = ch;
  22.     intext = FALSE;
  23.     while ((bufptr < buffer+MAXLINE)&&((ch = getch(TERMINAL,intext)) != CR && ch != LF))
  24.     {
  25.         if (ch == '\b')
  26.         {
  27.             if( bufptr > buffer)
  28.                 *bufptr--; 
  29.         }
  30.         else
  31.         {
  32.             if (bufptr == buffer && ch == ' ')
  33.                 ;
  34.             else
  35.             {
  36.                 *bufptr++ = ch;
  37.                 if (ch == TEXTDEL)
  38.                     intext = TRUE;
  39.             }
  40.         }
  41.     }
  42.     putch(TERMINAL,LF);
  43.     *bufptr = ENDSTR;
  44.     if (buffer[0] == ENDSTR)
  45.         return(0);
  46.     while (whitesp(buffer[0]))
  47.         shiftarg(buffer,1);
  48.     for (i = 0,intext = FALSE;buffer[i] != ENDSTR;i++)
  49.         if (whitesp(buffer[i]))
  50.             intext = FALSE;
  51.         else if (intext == FALSE)
  52.         {
  53.             intext = TRUE;
  54.             ++length;
  55.         }
  56.     return(length);
  57. }
  58.  
  59.  
  60. /*
  61. This routine inputs a string from the terminal, strips of leading
  62. blanks, allows for destructive backspacing while on the line, and returns 
  63. the number of arguments seperated by a space, along with the line.
  64. IT DOES NOT ECHO THE RETURN CHARACTER TO THE TERMINAL!!!
  65. */
  66.  
  67.  
  68. getlineNR(buffer)
  69. char *buffer;    /* string to put the typed line into */
  70. {
  71. register char ch;    /* charachter inputed */
  72. register char *bufptr;    /* pointer to within gbuffer */
  73. register int length;    /* length of string inputed */
  74. register int intext;    /* flag for being between text delimiters or blanks */
  75. register int i;        /* loop counter */
  76.  
  77.     length = 0;
  78.     ch = ' ';
  79.     bufptr = buffer;
  80.     *bufptr = ch;
  81.     intext = FALSE;
  82.     while ((bufptr < buffer+MAXLINE)&&((ch = getch(TERMINAL,intext)) != CR && ch != LF))
  83.     {
  84.         if (ch == '\b')
  85.         {
  86.             if( bufptr > buffer)
  87.                 *bufptr--; 
  88.         }
  89.         else
  90.         {
  91.             if (bufptr == buffer && ch == ' ')
  92.                 ;
  93.             else
  94.             {
  95.                 *bufptr++ = ch;
  96.                 if (ch == TEXTDEL)
  97.                     intext = TRUE;
  98.             }
  99.         }
  100.     }
  101.     *bufptr = ENDSTR;
  102.     if (buffer[0] == ENDSTR)
  103.         return(0);
  104.     while (whitesp(buffer[0]))
  105.         shiftarg(buffer,1);
  106.     for (i = 0,intext = FALSE;buffer[i] != ENDSTR;i++)
  107.         if (whitesp(buffer[i]))
  108.             intext = FALSE;
  109.         else if (intext == FALSE)
  110.         {
  111.             intext = TRUE;
  112.             ++length;
  113.         }
  114.     return(length);
  115. }
  116.  
  117. /* **************************************************** */
  118.  
  119. getch(addr,intext)
  120. int addr,intext;
  121. {
  122. register char ch;
  123.  
  124.     while ((get8(addr + SRX) & 1) == 0)
  125.         ;
  126.     ch = get8(addr + RBX);
  127.     if (!intext && CONVCAP && (ch >= 'A') && (ch <= 'Z'))
  128.         ch = ch + 'a' - 'A';
  129.     if (addr == TERMINAL)
  130.         putch(TERMINAL,ch);
  131.     return(ch);
  132. }
  133.  
  134. /* **************************************************** */
  135.  
  136.